﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom;

namespace CodeDomHelper.CodeDom
{

    [Serializable()]
    [System.Diagnostics.DebuggerStepThrough()]
    public class ParameterExp : CodeParameterDeclarationExpression, IType
    {

        public ParameterExp() : base() 
        {
            Type = new TypeExp(TypeExp.Object);
        }

        public ParameterExp(TypeExp type, string name)
            : base(type, name) 
        {
            Type = new TypeExp(type);
        }

        public ParameterExp(TypeExp type, string name, FieldDirection direction)
            : this(type, name)
        {
            this.Direction = direction;
        }

        public ParameterExp(string type, string name)
            : base(type, name) 
        {
            Type = new TypeExp(type);
        }

        public ParameterExp(string type, string name, FieldDirection direction)
            : this(type, name)
        {
            this.Direction = direction;
        }

        public ParameterExp(Type type, string name)
            : base(type, name) 
        {
            Type = new TypeExp(type);
        }

        public ParameterExp(Type type, string name, FieldDirection direction)
            : this(type, name)
        {
            this.Direction = direction;
        }

        public TypeExp Type { get; private set; }

        public static implicit operator VariableExp(ParameterExp property)
        {
            return new VariableExp(property.Name, property.Type);
        }

        public static explicit operator ParameterExp(VariableExp variable)
        {
            return new ParameterExp(variable.Type, variable.VariableName);
        }

    }
}
